package com.ming.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2017/6/15.
 */

@Controller

public class LoginController{

    @RequestMapping(value = "login",method = RequestMethod.GET)

    public String getLogin(){

        return "user/login";
    }

    @RequestMapping(value = "login",method = RequestMethod.POST)
    public String getLogin(HttpServletRequest request){

        String username = request.getParameter("username");
        String password = request.getParameter("password");

        if(username.equals("admin")&&password.equals("admin")){
            request.getSession().setAttribute("admin",username);

        }
        return "redirect:/user/userList";

    }

}
